#ifndef lib_manager
#define ilb_manager



#include "db.h"
#include "db_op.h"

#include "book_info.h"

class Database_Manager{
protected:
    Database* db;
    Database_Operater* operater;
public:
    Database_Manager(Database* db) : db(db) {}
};




class Library_UpdateManager: public Database_Manager {
public:
    Library_UpdateManager(Database* db) : Database_Manager(db){
        operater = new Libaray_Operater();
    }
    ~Library_UpdateManager(){
        delete operater;
    }

    // 添加图书信息
    bool AddBookInfo(BookInfo book_info);

    // 图书采购
    bool BookPurchase(PurchaseInfo purchase_info);

    // 图书淘汰
    bool BookElimination(DiscardInfo discard_info);

    // 图书租借
    bool BookRent(BorrowInfo borrow_info);

    // 图书归还
    bool BookReturn(const std::string& borrow_id, time_t return_date);
private:
    // 管理图书数量
    bool UpdateBookQuantity(const std::string& book_id, int quantity_change);
};

class Library_QueryManager: public Database_Manager {
public:
    Library_QueryManager(Database* db) : Database_Manager(db){
        operater = new Libaray_Operater();
    }
    ~Library_QueryManager(){
        delete operater;
    }

    // 查询所有图书信息及其库存情况
    QueryResult GetBooksInfo();

    // 查询采购记录
    QueryResult GetPurchasesInfo();

    // 查询淘汰记录
    QueryResult GetDiscardsInfo();

    // 查询租借情况
    QueryResult GetBorrowsInfo();
private:
    QueryResult ExecuteQuery(const std::string& query);
};



class Library_StatisticsManager: public Database_Manager {
public:
    Library_StatisticsManager(Database* db) : Database_Manager(db) {
        operater = new Libaray_Operater();
    }
    ~Library_StatisticsManager() {
        delete operater;
    }

    // 统计图书采购情况
    QueryResult GetPurchasesStatistics();

    // 统计图书库存情况
    QueryResult GetInventoryStatistics();

    // 统计图书淘汰情况
    QueryResult GetDiscardsStatistics();

    // 统计图书租借情况
    QueryResult GetBorrowsStatistics();

private:
    // 执行查询并返回结果
    QueryResult ExecuteQuery(const std::string& query);
};













# endif